package com.mayblackcat.dy.dao;

import com.mayblackcat.dy.entity.Video;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoDao {
    //按视频标题和内容搜索
    @Select("select * from t_video where title like CONCAT('%',#{keyword},'%') or description like CONCAT('%',#{keyword},'%')")
    List<Video> searchHotVideo(String keyword);

    @Select("select * from t_video order by createTime desc")
    List<Video> searchRecommendVideo();

    @Update("update t_video set likes=#{likes},commentCount=#{commentCount} where id=#{id}")
    void updateLikesById(Video video);

    @Select("select * from t_video where id=#{id}")
    Video getWatchVideoByIds(long id);

    @Insert("insert into t_video(title,content,likes,description,commentCount,videoUserId,videoUserAvatar,createTime) values(#{title},#{content},#{likes},#{description},#{commentCount},#{videoUserId},#{videoUserAvatar},#{createTime})")
    boolean publishVideo(Video video);
}
